package edu.cicese.tm;

import java.awt.Color;
import java.awt.Polygon;
import java.util.List;

/**
 * Created by: Eduardo Quintana Contreras
 * Date: 24/02/11
 * Time: 04:04 PM
 */
public class Space implements Comparable<Space>{
    private String spaceID;
    private String spaceName;
    private Color spaceColor;
    private Polygon spaceArea;

    public Space(String spaceName, Color spaceColor, List<Integer> xCoord, List<Integer> yCoord) {
        this.spaceName = spaceName;
        this.spaceColor = spaceColor;
        this.spaceArea = new Polygon(toIntArray(xCoord), toIntArray(yCoord), xCoord.size());
    }

	public Space(String spaceID, String spaceName) {
		this.spaceID = spaceID;
		this.spaceName = spaceName;
	}

    public String getSpaceName() {
        return spaceName;
    }

    public void setSpaceName(String spaceName) {
        this.spaceName = spaceName;
    }

    public Color getSpaceColor() {
        return spaceColor;
    }

    public void setSpaceColor(Color spaceColor) {
        this.spaceColor = spaceColor;
    }

    public int[] toIntArray(List<Integer> list) {
		int[] array = new int[list.size()];
		for (int i = 0; i < list.size(); i++) {
			array[i] = list.get(i);
		}
		return array;
	}

    public void setSpaceArea(List<Integer> xCoord, List<Integer> yCoord) {
        this.spaceArea = new Polygon(toIntArray(xCoord), toIntArray(yCoord), xCoord.size());
    }

    public Polygon getSpaceArea() {
        return spaceArea;
    }

	public int compareTo(Space s) {
		return spaceName.compareToIgnoreCase(s.getSpaceName());
	}

	public String getSpaceID() {
		return spaceID;
	}
}
